﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Trangchu.aspx.cs" Inherits="Trangchu" %>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.IO" %>
<%@Register TagPrefix="uc" TagName="SLIDER" Src="~/Slide.ascx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <Title>Trang chủ</Title>
    <div id="slider">
        <div id="info_title">
            <span class="text_title">THÔNG TIN HOẠT ĐỘNG BÁO CÁO KH-CN</span>
        </div>
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div id="post_wrapper">
                    <%
            
                        int trang = Convert.ToInt32(Request.QueryString["page"]);
                        int sobaihienthi = 3;
                        int batdautu = trang * 3;
                        BieumauDataContext db = new BieumauDataContext();
                        var dt = from p in db.tblBanTins.Skip(batdautu).Take(sobaihienthi) select new { id = p.IDTin, tieude = p.TieuDe, noidung = p.NoiDung,noidungtomtat=p.NoiDungTomTat, ngaydang = p.NgayDang, loaitin = p.LoaiTin };

                        foreach (var vb in dt) 
                        {
                           
                        %>
                       <!--begin--><div class='post_news'>
                                 <div class='post_title'>
                                  <a href='View.aspx?mode=BT&bantin=<%=vb.id %>'>    <%=vb.tieude %> </a>
                            
                            </div>
                                    <div class='post_content'>
                          <p><%=vb.noidungtomtat%>...&nbsp;<a href='View.aspx?mode=BT&bantin=" + vb.id + "'>Xem chi tiết</a></p></div></div><!--end-->
                    <%
                        }
                    %>
                </div>
                <div id="view_more">
                    <div id="title_view_more">
                        <h5>Các văn bản khác</h5>
                    </div>
                </div>
                <div id="view_more_content">
                    <div id="view_more_items">
                        <% 
                     
                            int total = db.tblBanTins.Count();
                            int set = 1;
                            if (total == 1)
                            {
                                set = total;
                            }
                            else if (total > 1)
                            {
                                set = total / sobaihienthi;
                            }


                            int start_more = batdautu + sobaihienthi;
                            if (trang == set)
                            {
                                var more = from p in db.tblBanTins.Skip(0).Take(6) select new { id = p.IDTin, tieude = p.TieuDe, noidung = p.NoiDung, ngaydang = p.NgayDang, loaitin = p.LoaiTin };
                                foreach (var i in more)
                                {
                                    %>

                                    <div class='items_view'><a href='View.aspx?mode=BT&bantin=<%=i.id%>'><%= i.tieude%></a></div>

                        <%
                                }
                            }
                            else
                            {
                                var more = from p in db.tblBanTins.Skip(start_more).Take(sobaihienthi + 2) select new { id = p.IDTin, tieude = p.TieuDe, noidung = p.NoiDung, ngaydang = p.NgayDang, loaitin = p.LoaiTin };
                                foreach (var i in more)
                                {
                                    %>
                                  <div class='items_view'><a href='View.aspx?mode=BT&bantin=<%=i.id%>'><%= i.tieude%></a></div>
                        <%
                                }
                            }
                  

                        %>
                    </div>
                    <div id="paging"><ul>
                        <%
                          
                            int n = Convert.ToInt32(Request.QueryString["page"]);
                            if (n<=3)
                            {
                               %>

                               <li><a href='Trangchu.aspx?page=0' >« Đầu</a></li>
                       <%
                                if (set <= 5)
                                {
                                    for (int i = 1; i < set; i++)
                                    {
                                        Response.Write("<li><a ");
                                        if (i == Convert.ToInt32(Request.QueryString["page"].ToString()))
                                        {
                                            Response.Write("class='actived_page' href='Trangchu.aspx?page=" + i + "'>" + i + "</a></li>");
                                        }
                                        else
                                        {
                                            Response.Write("href='Mauvanban.aspx?page=" + i + "'>" + i + "</a></li>");
                                        }
                                      
                        
                                    }
                                }
                                else
                                {

                                    for (int i = 1; i <= 5; i++)
                                    {

                                          Response.Write("<li><a ");
                                        if (i == Convert.ToInt32(Request.QueryString["page"].ToString()))
                                        {
                                            Response.Write("class='actived_page' href='Trangchu.aspx?page=" + i + "'>" + i + "</a></li>");
                                        }
                                        else
                                        {
                                            Response.Write("href='Mauvanban.aspx?page=" + i + "'>" + i + "</a></li>");
                                        }
                                      

                                    }
                                }
                                Response.Write("... <li><a href='Trangchu.aspx?page=" + set + "'>Cuối »</a></li>");
                            }
                            else
                            {
                                
                                  
                                    Response.Write("<li><a href='Trangchu.aspx?page=0' >« Đầu</a></li>");      
                                    for (int i = n - 2; i <= n + 2; i++)
                                    {
                                        if (i == set)
                                            break;
                                          Response.Write("<li><a ");
                                        if (i == Convert.ToInt32(Request.QueryString["page"].ToString()))
                                        {
                                            Response.Write("class='actived_page' href='Trangchu.aspx?page=" + i + "'>" + i + "</a></li>");
                                        }
                                        else
                                        {
                                            Response.Write("href='Mauvanban.aspx?page=" + i + "'>" + i + "</a></li>");
                                        }
                                      

                                    }

                                    Response.Write("... <li><a href='Trangchu.aspx?page=" + set + "'>Cuối »</a></li>");
                                
                            }
                            
                           
                        %>
                        </ul>
                    </div>
                    







                </div>
           </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
   
    
     <!--Begin advertise-->
    <div id="advertise">
        
         <%--    <uc:SLIDER Id="slider" runat="Server" />--%>
             <%
                    BieumauDataContext db1 = new BieumauDataContext();
                    var qc_dn=from p in db1.tblDoanhNghiepTuNhans select new {p.TenDoanhNghiep,p.Website,p.DiaChi,p.Logo};
                     %>
            <div id="mcts1">
                <%
                    int i = 0;
                   
                    foreach (var donvi in qc_dn)
                    {
                        
                         %>
                 <a href='<%=donvi.Website %>' ><img src='<%=donvi.Logo %>' width="94" height="80" onmouseover='tooltip.pop(this, "#DNNN<%=i %>")' /></a>                                          
                      <%
                i++;
            
            } %>
            </div>

       <div style="display:none;">
           <%
               int j = 0;
               foreach (var donvi in qc_dn)
               { %>
            <div id="DNNN<%=j %>">     
                <div class="tips">
                    <table width="100%">
                        <tr>
                            <td rowspan="3" style="width: 77px">
                                <img alt="" src="<%=donvi.Logo %>" style="width: 95px; height: 89px" /></td>
                            <td align="right" style="width: 67px; height: 11px"><h5>Tên đơn vị:</h5></td>
                            <td align="justify" style="height: 11px"><h5 style="font-size:11px !important;font-weight:400;"><%=donvi.TenDoanhNghiep %></h5></td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 67px; height: 1px;"><h5 style="margin-right: 0px">Website:</h5></td>
                            <td align="justify" style="height: 1px"><h5 style="font-size:11px !important;font-weight:400;"><a target="_blank" href="<%=donvi.Website %>"><%=donvi.Website %></a></h5></td>
                        </tr>
                        <tr>
                            <td align="right" style="width: 67px; "><h5>Địa chỉ:</h5></td>
                            <td align="justify"><br /><h5 style="font-size:11px !important;font-weight:400; vertical-align: middle;"><%=donvi.DiaChi %></h5></td>
                        </tr>
                    </table>
                </div>
               
            </div>
            
            <%
                j++;
            
            } %>

        </div>
    </div>

</asp:Content>

